﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Omniscient.Foundation.ApplicationModel;
using Omniscient.TimeTracker.BusinessModel.Commands;

namespace Omniscient.TimeTracker.TaskBarMenu
{
    /// <summary>
    /// Interaction logic for NotfierMenu.xaml
    /// </summary>
    public partial class NotifierContextMenu : ContextMenu
    {
        public NotifierContextMenu(TaskBarMenuModel model)
        {
            InitializeComponent();

            // Assign tasks to menu
            StartTaskCommand startTask = ApplicationManager.Current.ObjectContainer.Get<StartTaskCommand>();
            ChangeTaskCategoryCommand changeTask = ApplicationManager.Current.ObjectContainer.Get<ChangeTaskCategoryCommand>();
            StopTaskCommand stopTask = ApplicationManager.Current.ObjectContainer.Get<StopTaskCommand>();

            if (startTask != null && changeTask != null && stopTask != null)
            {
                Resources.Add("commandStartTask", startTask);
                Resources.Add("commandChangeCategory", changeTask);
                Resources.Add("commandStopTask", stopTask);
                Resources.Add("commandCreateTask", new NonExecutableCommand());
            }
            MenuStartTask.ItemsSource = model.Clients;
            MenuChangeTaskCategory.ItemsSource = model.Categories;
        }

        private void menuAddNewTaskClick(object sender, RoutedEventArgs e)
        {
            System.Windows.MessageBox.Show("Add a new task to a project...", "Add new task", MessageBoxButton.OK);
        }
    }

    public class NonExecutableCommand : ICommand
    {
        #region ICommand Members

        public bool CanExecute(object parameter)
        {
            return false;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            throw new NotImplementedException();
        }

        #endregion
    }


}
